home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 4 / Meeting Pearls Vol. IV (1996)(GTI - Schatztruhe)[!].iso / Pearls / dev / ASM-Src / NewStartup / Startup_example.s < prev    next >
Text File  |  1996-06-06  |  5KB  |  142 lines

  1. *******************************************************************************
  2. *                                          *
  3. *    Startup example for "Startup.asm" version 3.6                  *
  4. *                                          *
  5. *    © 1995,1996 Kenneth C. Nilsen                          *
  6. *                                          *
  7. *    See bottom line!                              *
  8. *                                          *
  9. *******************************************************************************
  10.  
  11. StartSkip    =    0        ;0=WB/CLI, 1=CLI only (eg. from AsmOne)
  12. Processor    =    68000        ;0/680x0 (= 0 is faster than 68000)
  13. MathProc    =    0        ;FPU: 0(none)/68881/68882/68040
  14.  
  15.  
  16.     incdir    inc:            ;your include dir
  17.     include    Startup.asm        ;our file
  18. *------------------------------------------------------------------------------
  19. *## here is our init section (Init: label and DefLib macro are required)
  20. *------------------------------------------------------------------------------
  21.  
  22.     dc.b    "$VER: Example 3.6 (06.06.96)",0
  23.     even
  24.  
  25. Init:
  26. AsmOne:    TaskName "Startup test 1.0"    ;set our task name
  27. ;Devpac:
  28. ;Barfly:    TaskName "<Startup test 1.0>"
  29.  
  30.     TaskPri    1            ;set task pri
  31.  
  32.     DefLib    intuition,0        ;open intuition.library ver. 0
  33.     DefLib    dos,37            ;open dos.library ver. 37
  34.     DefEnd                ;ALWAYS REQUIRED!!!
  35.  
  36. *------------------------------------------------------------------------------
  37. ;## our main example code comes from here (Start: label is required!)
  38. *------------------------------------------------------------------------------
  39.  
  40. Start:    LibBase    dos            ;use dos.library base
  41.  
  42.     jsr    -60(a6)            ;Output()
  43.     move.l    d0,d1            ;copy handler
  44.     beq.b    .noOut            ;null? then skip
  45.  
  46.     move.l    #Text,d2        ;pointer to our text
  47.     move.l    #TextL,d3        ;length of text
  48.     jsr    -48(a6)            ;Write() (to handler)
  49.  
  50. *------------------------------------------------------------------------------
  51. ;## if we started from Wb then blink (just to differ a little)
  52. *------------------------------------------------------------------------------
  53.  
  54. .noOut    StartFrom            ;a macro which tells you where the prg.
  55.     beq.b    .cli            ;started from. (=0 cli / <>0 wb)
  56.  
  57. .wb    LibBase    intuition        ;use "LibBase" to get library bases
  58.  
  59. *------------------------------------------------------------------------------
  60. ;## now intuition.library base is put into A6 and we can start using it:
  61. *------------------------------------------------------------------------------
  62.  
  63.     move.l    60(a6),a0        ;frontmost screen (hehe, wonder how?)
  64.     jsr    -96(a6)            ;DisplayBeep(), blink the screen
  65.  
  66.     TaskPointer            ;get pointer to this task in d0.
  67.                     ;use it what you want :)
  68. *------------------------------------------------------------------------------
  69. ;here we demostrade the argument parsing. You get one seperate argument by
  70. ;each time you use the "NextArg" macro. Pointer to argument [0] in d0 or NULL:
  71. *------------------------------------------------------------------------------
  72.  
  73. .cli    NextArg                ;macro which gives us the pointer to
  74.     beq.b    .exit            ;our arg. in D0 (or NULL in D0)
  75.                     ;Branch EQual if end of args.
  76.     move.l    d0,d2            ;we store pointer to buffer in D2
  77.  
  78. *------------------------------------------------------------------------------
  79. ;## print arguments to default output (in cli) to see some actions:
  80. *------------------------------------------------------------------------------
  81.  
  82.     LibBase    dos            ;internal macro (dosbase in a6)
  83.  
  84.     jsr    -60(a6)            ;Output()
  85.     move.l    d0,d1            ;handler
  86.     beq.b    .exit            ;no handler? then exit printing
  87.  
  88.     moveq    #0,d3            ;length
  89.     move.l    d2,a0            ;copy buffer address to a0
  90. .count    move.b    (a0)+,d0        ;get one byte from buffer
  91.     beq.b    .gotLen            ;found null, exit loop
  92.     addq    #1,d3            ;add one to length in D3
  93.     bra.b    .count            ;count some more...
  94.  
  95. .gotLen    jsr    -48(a6)            ;Write(), print argument in cli
  96.  
  97.     jsr    -60(a6)            ;Output()
  98.     move.l    d0,d1            ;output handler in D1
  99.     move.l    #Text,d2        ;pointer to text/linefeed
  100.     moveq    #1,d3            ;length
  101.     jsr    -48(a6)            ;Write(), print linefeed in cli
  102.  
  103.     bra.b    .cli            ;repeat until no args are left
  104.  
  105. .exit    Return    0            ;return code and bye bye!
  106.  
  107. *-----------------------------------------------------------------------------*
  108. ;## Our data section for this example source:
  109. *-----------------------------------------------------------------------------*
  110.  
  111. Text    dc.b    10,'Startup.asm example 3.5',10
  112.     dc.b    'Give some arguments to test the NextArg macro:',10,10
  113. TextL    =*-Text
  114.  
  115. *-----------------------------------------------------------------------------*
  116. *######    BOTTOM LINE
  117. *-----------------------------------------------------------------------------*
  118. ;    Remember that supporting Workbench startup will make more people happy!
  119. ;    :) (like that guy) and by using this startup code you have easy support
  120. ;    for that AND extra features like reading arguments without having to
  121. ;    parse the line, use ReadArgs(), or remove spaces and quotes yourself.
  122. ;    You can also easily make a version string into your binary programs and
  123. ;    set your own task name. You have even control on where your program
  124. ;    where started from. You can also prevent your program to crash on a
  125. ;    machine with a lower processor than you require. The same thing about
  126. ;    the FPU.
  127. ;
  128. ;    The assembled startup code is in itself only about 1Kb! and that's
  129. ;    worth making your program safe!
  130. ;
  131. ;    Feel free to contact me if any problems occure or if you want features
  132. ;    included. If you change the Startup.asm source it would be nice to see
  133. ;    what you have done :)
  134. ;
  135. ;    Add: kenneth@norconnect.no
  136. ;
  137. ;    InterMedia consulting
  138. ;    Attn: Kenneth Nilsen
  139. ;    Kvernhusrenen 31
  140. ;    N-5227 S-Neset
  141. ;    Norway
  142.